﻿
#region USING

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

#endregion

namespace Learning.ConwaysGameOfLife
{
    public static class Extensions
    {
		#region Methods (4) 

		// Public Methods (2) 

        public static int Next(this int value)
        {
            return value + 1;
        }

        public static int Previous(this int value)
        {
            return value - 1;
        }
		// Internal Methods (2) 

        internal static void AddNeighborCell(this IList<Cell> neighbors, IList<Cell> cells, Cordinate cordinate)
        {
            Cell cell = cells.FindCell(cordinate);

            if (cell != null)
            {
                neighbors.Add(cell);
            }
        }

        internal static Cell FindCell(this IList<Cell> cells, Cordinate cordinate)
        {
            return cells
                .Where<Cell>(i => i.Cordinate == cordinate)
                .FirstOrDefault<Cell>();
        }

		#endregion Methods 
    }
}